#include"Sort.h"
#include"Stack.h"
#include"stdio.h"

void QuickSortNonR(int* a, int begin, int end)
{

	ST s;
	STInit(&s);
	STPush(&s, end);
	STPush(&s, begin);

	while (!STEmpty(&s))
	{
		int left = STTop(&s);
		STPop(&s);
		int right = STTop(&s);
		STPop(&s);
		int keyi = PartSort3(a, left, right);
		if (left < keyi - 1)
		{
			STPush(&s, keyi - 1);
			STPush(&s, left);
		}
		if (keyi+1< right)
		{
			STPush(&s, right);
			STPush(&s, keyi+1);
		}
	}
	STDestroy(&s);
}